<template>
  <t-dialog
    :visible="visible"
    :header="title"
    :body="content"
    @update:visible="handleVisibleChange"
    @confirm="onConfirm"
    @close="onClose"
  >
    <template #footer>
      <t-space>
        <t-button theme="primary" @click="onConfirm">确定</t-button>
        <t-button theme="default" @click="onClose">取消</t-button>
      </t-space>
    </template>
  </t-dialog>
</template>

<script setup lang="ts">
/**
 * ContractDialog
 *
 * @version 1.0.1
 * @author FengJinJian
 * @date 2024/03/19 10:00
 */

const props = defineProps<{
  visible: boolean;
  title: string;
  content: string;
}>();

const emit = defineEmits<{
  'update:visible': [value: boolean];
  'confirm': [];
}>();

// 处理对话框可见性变化
const handleVisibleChange = (value: boolean) => {
  emit('update:visible', value);
};

// 确认操作
const onConfirm = () => {
  emit('confirm');
};

// 关闭对话框
const onClose = () => {
  emit('update:visible', false);
};
</script>

<style lang="less" scoped>
.t-dialog {
  &__footer {
    padding: 16px 24px;
  }
}
</style>
